package parallels.servertech.client.commands;

import java.io.EOFException;
import java.io.IOException;

import parallels.servertech.client.CommandContext;
import parallels.servertech.client.CommandHandler;

public class ShutdownHandler implements CommandHandler {
	private static final String COMMAND_NAME = "shutdown";
	
	@Override
	public void handle(String[] args, CommandContext ctx) {
		ctx.getOut().println("sending shutdown request");
		
		try {
			ctx.send(COMMAND_NAME);
		} catch (EOFException eof) {
			ctx.getOut().println("server shutdown completed");
		} catch (IOException ioe) {
			ctx.getOut().printf("failed to send: %s(%s)%n", ioe.getClass().getName(), ioe.getMessage());
		}
	}
}
